package com.azunitech.jms.ejb;

import javax.ejb.Stateless;

import static javax.ejb.TransactionAttributeType.*;

import javax.ejb.SessionContext;
import javax.ejb.Stateful;
import javax.ejb.TransactionAttribute;
import javax.ejb.Remote;
import javax.ejb.EJB;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.interceptor.AroundInvoke;
import javax.interceptor.Interceptors;
import javax.interceptor.ExcludeClassInterceptors;
import javax.interceptor.InvocationContext;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;

import com.azunitech.jms.common.domains.PartsEntity;
import com.azunitech.jms.repos.PartsRepository;
import com.google.inject.Inject;

/**
 * Session Bean implementation class HelloServiceImpl
 */
@Stateless(mappedName = "helloService")
@Interceptors({AuditInterceptor.class})
@UsesGuice
public class HelloServiceImpl implements HelloService {

	private static Logger LOG = Logger.getLogger(HelloServiceImpl.class);
	private static String DEFAULT_NAME = "World"; 

	@Inject PartsRepository repo;
	
	
	public String greet(String name) {
		
		
		String finalName = StringUtils.defaultIfEmpty(name, DEFAULT_NAME);
		String greeting =  "Hello "+finalName;
		LOG.debug(greeting);
		repo.init();
		PartsEntity entoty = repo.getParts("sdfsdf");
		return greeting;
	}
	
	@PreDestroy
	public void preDestroy() {
		System.out.println("*******************Invoking method: preDestroy()");  
	}
	
	@PostConstruct
    public void initialize() {
		System.out.println("$$$$$$$$$$$$$$$$$$$$Invoking method: @PostConstruct()");  
    }
}
